<?php
defined('IN_IA') or exit('Access Denied');
global $_GPC, $_W;
$aouthkey = $_GPC['aouthkey'];
$page = $_GPC['page'];
$itemid = $_GPC['itemid'];
$cate_id = $_GPC['cate_id'];
$setting = $this->baseset($_W['uniacid']);
$nbkey = $setting['nbkey'];
$yj_min = $setting['yj_min'];
$sy_min = $setting['sy_min'];
$jg_min = $setting['jg_min'];
$page_min = $setting['page_min'];
$tm_min = $setting['tm_min'];
$yhj_min = $setting['yhj_min'];
$xl_min = $setting['xl_min'];
if (empty($page_min)) {
	$page_min = 20;
}
if ($aouthkey == $nbkey) {
	$plus_cate = "";
	$plus_itemid = "";
	$plus_yj_min = "";
	$plus_sy_min = "";
	$plus_jg_min = "";
	$plus_yhj_min = "";
	$plus_xl_min = "";
	$plus_tm_min = "";
	$plus_xl_min = "";
	$plus_yhj_min = "";
	if ($tm_min == 1) {
		$plus_tm_min .= " AND CONCAT(`istmall`) = '1'";
	}
	if (!empty($cate_id)) {
		$plus_cate .= " AND CONCAT(`cate_id`) = '{$cate_id}'";
	}
	if (!empty($yhj_min) && $yhj_min != 0) {
		$plus_yhj_min .= " AND CONCAT(`itemyhj_yl`) >= '{$yhj_min}'";
	}
	if (!empty($xl_min) && $xl_min != 0) {
		$plus_xl_min .= " AND CONCAT(`itemmsell`) >= '{$xl_min}'";
	}
	if (!empty($itemid)) {
		$plus_itemid .= " AND CONCAT(`itemid`) = '{$itemid}'";
	}
	if (!empty($yj_min) && $yj_min != 0) {
		$plus_yj_min .= " AND CONCAT(`shouru_bili`) >= '{$yj_min}'";
	}
	if (!empty($sy_min) && $sy_min != 0) {
		$plus_sy_min .= " AND CONCAT(`shouru_yongjin`) >= '{$sy_min}'";
	}
	if (!empty($jg_min) && $jg_min != 0) {
		$plus_jg_min .= " AND CONCAT(`itemfee`) >= '{$jg_min}'";
	}
	$nowpage = $_GPC['page'];
	$pindex = max(1, intval($nowpage));
	$psize = $page_min;
	$list = pdo_fetchall("SELECT id,status,tktype,istmall,cate_id,itemid,itemurl,itemsurl,itemyhj_url,link_jihua,quan_link,isdx FROM " . tablename($this->tableitemall) . " WHERE uniacid = '{$_W['uniacid']}' $plus_cate $plus_itemid $plus_yj_min $plus_sy_min $plus_jg_min $plus_tm_min $plus_yhj_min $plus_xl_min order by displayorder desc,id desc LIMIT " . ($pindex - 1) * $psize . ',' . $psize);
	$total = pdo_fetchcolumn('SELECT COUNT(id) FROM ' . tablename($this->tableitemall) . " WHERE uniacid = '{$_W['uniacid']}' $plus_cate $plus_itemid $plus_yj_min $plus_sy_min $plus_jg_min $plus_tm_min $plus_yhj_min $plus_xl_min");
	if ($list) {
		exit(json_encode(array('isok' => 1, 'page' => $pindex, 'total' => $total, 'content' => $list)));
	} else {
		exit(json_encode(array('isok' => 0, 'page' => $pindex, 'total' => $total, 'content' => 'none')));
	}
} else {
	exit(json_encode(array('isok' => 'aouthkey error!')));
}